package com.AEWMS.Test;

import com.AEWMS.Dao.ScoreWarningRank;
import com.AEWMS.Pojo.AdminScoreView;
import com.AEWMS.Service.AdminService;
import com.AEWMS.Service.AttendDetailService;
import com.AEWMS.Service.CourseScoreService;
import com.AEWMS.Service.ScoreWarnRankService;
import com.alibaba.fastjson.JSON;

import java.util.ArrayList;

public class AdminTest {
    public static void main(String[] args) {
//        AdminService s = new AdminService();
//        System.out.println(JSON.toJSONString(s.findAllAdmin()));
//        System.out.println(s.findAdmById("001"));
//        Admin a = new Admin();
//        a.setId("003");
//        a.setName("周六福");
//        a.setPassword("123");
//        a.setTel("183138");
//        a.setSex("女");
//        a.setType("admin");
//        System.out.println(s.insertAdm(a));
//        if(s.insertAdm(a)){
//            System.out.println("succeed");
//        }else{
//            System.out.println("defeat");
//        }
//        a.setId("000");
//        a.setTel("12310");
//        System.out.println(s.updateAAdm(a));
//        if(s.insertAdm(a)){
//            System.out.println("succeed");
//        }else{
//            System.out.println("defeat");
//        }
//        if(s.deleteAdmById("001")){
//        System.out.println("succeed");
//        }else{
//            System.out.println("defeat");
//      }
//        AttendDetailService ds = new AttendDetailService();
//
//        System.out.println(JSON.toJSONString(ds.findAttendDetailById("117583030114")));

        CourseScoreService css = new CourseScoreService();
        ArrayList<AdminScoreView> as = css.findAllStudentScoreRankByyt("2020","春季学期");
        ScoreWarnRankService swrs = new ScoreWarnRankService();
        ArrayList<ScoreWarningRank> ss = swrs.findAllScoreWarningRankNotView();
        ArrayList<AdminScoreView> temp = new ArrayList<>();
        for (AdminScoreView a : as){
            if (a.getBxFail() >= ss.get(0).getWarningStandardStart()) {
                a.setRank(ss.get(0).getWarningRank());
                break;
            }
            else {
                Double t = a.getBxFail() + a.getXxFail();
                for (ScoreWarningRank s : ss) {
                    if (t >= s.getWarningStandardStart() && t < s.getWarningStandardEnd()) {
                        a.setRank(s.getWarningRank());
                        break;
                    }
                }
            }
            temp.add(a);
        }
        System.out.println(JSON.toJSONString(temp));

;    }
}
